package com.atguigu.b_random;

import java.util.Random;
/*
    1. 如何取值 [1,10] 之间 :
        int num = r.nextInt(10) + 1;
    2. 如何取值 [-10,-1] 之间 :
        int num = -(r.nextInt(10) + 1);
    3. 如何取值 [m,n] 之间 :  //[21,79]
        int num = r.nextInt(n - m + 1) + m;
 */
public class Demo {
    public static void main(String[] args) {
        Random r = new Random();

        //生成一个[0-99]范围内容的随机整数
        //int num = r.nextInt(); //取值范围 : int的取值范围
        int num = r.nextInt(59) + 21; //取值范围 : int的取值范围

        for (int i = 0; i < 10; i++) {
            int num2 = r.nextInt(1, 10);
            System.out.println("num2 = " + num2);

        }


        System.out.println("num = " + num);
    }
}
